---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: chartmuseum
spec:
  accessModes:
  - ReadWriteOnce
  resources:
    requests:
      storage: 100Gi
  storageClassName: {{ storageClassName }}
---
apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app: chartmuseum
  name: chartmuseum
spec:
  replicas: 1
  selector:
    matchLabels:
      app: chartmuseum
  strategy:
    rollingUpdate:
      maxSurge: 25%
      maxUnavailable: 0
    type: RollingUpdate
  template:
    metadata:
      labels:
        app: chartmuseum
      name: chartmuseum
    spec:
      nodeSelector:
        nodetype: persistent
      containers:
      - args:
        - --port=8080
        - --storage-local-rootdir=/storage
        env:
        - name: CHART_POST_FORM_FIELD_NAME
          value: chart
        - name: DISABLE_API
          value: "false"
        - name: DISABLE_METRICS
          value: "true"
        - name: LOG_JSON
          value: "true"
        - name: PROV_POST_FORM_FIELD_NAME
          value: prov
        - name: STORAGE
          value: local
        image: {{registry_prefix}}:{{registry_port}}/{{ chartmuseum_image }}:{{ chartmuseum_version }}
        imagePullPolicy: IfNotPresent
        livenessProbe:
          failureThreshold: 3
          httpGet:
            path: /health
            port: http
            scheme: HTTP
          initialDelaySeconds: 5
          periodSeconds: 10
          successThreshold: 1
          timeoutSeconds: 1
        name: chartmuseum
        ports:
        - containerPort: 8080
          name: http
          protocol: TCP
        resources:
          limits:
            cpu: 50m
            memory: 100Mi
          requests:
            cpu: 50m
            memory: 100Mi
        readinessProbe:
          failureThreshold: 3
          httpGet:
            path: /health
            port: http
            scheme: HTTP
          initialDelaySeconds: 5
          periodSeconds: 10
          successThreshold: 1
          timeoutSeconds: 1
        volumeMounts:
        - mountPath: /storage
          name: storage-volume
      securityContext:
        fsGroup: 1000
      volumes:
      - name: storage-volume
        persistentVolumeClaim:
          claimName: chartmuseum
---
apiVersion: v1
kind: Service
metadata:
  labels:
    app: chartmuseum
  name: chartmuseum
spec:
  ports:
  - name: http
    port: 8080
    protocol: TCP
    targetPort: http
  selector:
    app: chartmuseum
  type: NodePort
---
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  labels:
    app: chartmuseum
  name: chartmuseum
spec:
  rules:
  - host: {{ kubeapps_chartmuseum_hostname }}
    http:
      paths:
      - path: /
        backend:
          serviceName: chartmuseum
          servicePort: 8080
